package com.tansun.easycare.rule.datamodel.service;

import java.util.List;
import java.util.Map;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.tansun.easycare.rule.codeblock.entity.RuleCodeblock;
import com.tansun.easycare.rule.common.model.Item;
import com.tansun.easycare.rule.common.model.ResponseVO;
import com.tansun.easycare.rule.common.service.RuleBaseService;
import com.tansun.easycare.rule.datamodel.entity.RuleDataDomain;
import com.tansun.easycare.rule.datamodel.entity.RuleDataparams;
import com.tansun.easycare.rule.datamodel.entity.RuleDataparamsInfo;
import com.tansun.easycare.rule.exception.BizException;

/**
 * 数据集变量Service
 *
 * @author lxs
 * @version 2017-02-17
 */
public interface RuleDataparamsService extends RuleBaseService<RuleDataparams> {

	public void moveAttribute(String sourceId,String targetId,String attrName,String projectcode) throws  Exception;
    /**
     * 根据数据集名和变量名查找变量
     */
    List<RuleDataparams> findParmByClassName(Map<String, Object> map);
	/**
	 * 查询全部RuleDataparams，获取以className.Name为key的Map
	 * @param projectCode
	 * @return
	 */
    Map<String,RuleDataparams> findParamsKeyClassNameDotNameByProjectCode(String projectCode);
	/**
	 * 查询全部RuleDataparams，获取以dataSetId为key的Map
	 * @param projectCode
	 * @return
	 */
    Map<String, List<RuleDataparams>> findParamsKeyDsetIdByProjectCode(String projectCode);

    List<RuleDataDomain> findDataDomainList(RuleDataDomain ruleDataDomain);
    
    List<RuleDataDomain> findDataDomainListByDomainIds(List<String> domainIds) throws BizException;

    void saveParamsAndDomain(RuleDataparams ruleDataparams, String domainDataStr);
    
    void saveParamsAndDomain(RuleDataparams ruleDataparams, List<Item> domainDataStr) throws Exception;

    void deleteRuleDataparamsById(String id) throws BizException;
    
    void deleteRuleDataparamsByIds(List<String> ids) throws BizException;

    List<RuleDataparams> findRuleDataparamsByMap(Map<String, Object> map);

    void insertBatchDomains(List<RuleDataDomain> list);
    /**
     * 保存函数变量
     * @param ruleDataparams
     */
    public void saveFuncParam(RuleDataparams ruleDataparams)throws Exception;
    public ResponseVO validate(RuleDataparams rulefuncparam,String functionName,RuleCodeblock funcBlock)throws Exception;
    public Map<String,String>  getdataparams(String projectcode);
    
    
    List<RuleDataparams> findFunctionParam(Map<String,String> map);
    
    List<String>   findClassParam(Map<String,String> map);
    
	Map<String,String>  findParamMap(Map<String,String> map);

    /**
     * 查找数据集
     */
    List<RuleDataparams> queryRuleDataList(RuleDataparams ruleparams);
    
    /**
     * 根据变量中文名精确查找数据集(用于校验中文名是否重复)
     */
    List<RuleDataparams> findChznList(RuleDataparams ruleparams);
    
    /**
     * 函数变量的审批完成
     * @param ids
     */
	public void complementApproval(List<String> ids);

    List<RuleDataparamsInfo> findListWithStatus(RuleDataparamsInfo rd);
    
	/**
	 * map 
	 * @param map
	 */
	void updateDataSetId(String oldDataSetId,String newDataSetId);
	
	/**
	 *更新变量
	 * @param list
	 */
	void updatParam(List<RuleDataparams> list);
	
	/**
     * 根据项目信息查询对应的函数变量
     * @param page
     * @param RuleDataparamsInfo
     * @return
     */	
	public PageInfo<RuleDataparamsInfo> findFuncParamPage(Page<RuleDataparamsInfo> page,
			RuleDataparamsInfo ruleDataparamsInfo);
    /**
     * 更新关联层级ID（初始化）
     * @param condition
     * @return
     */
    public int updateRankId(RuleDataparams condition);
    
    void  saveAndUpdateRef(RuleDataparams  ruleDataparams) throws Exception;
}